//
//  AMPSADJGSDKManagerAdapter.m
//  AdScopeDemo
//
//  Created by apple on 2025/5/22.
//

#import "AMPSADJGSDKManagerAdapter.h"
#import <ADJgSDK/ADJgSDK.h>
#import <ADJgKit/ADJgKitLogging.h>

@implementation AMPSADJGSDKManagerAdapter

static AdScopeMediationAdapterInitSDKState _initState = kAdScopeMediationAdapterInitSDKStateNormal;

+ (AdScopeMediationAdapterInitSDKState)initState {
    return _initState;
}

+ (void)setInitState:(AdScopeMediationAdapterInitSDKState)initState {
    _initState = initState;
}

+ (void)startAsyncWithAppId:(NSString *)appId
              configuration:(AMPSAdSDKConfiguration *)configuration
                    results:(AMPSCustomAdapterSDKInitStatusResults)adapterResult {
    AMPSADJGSDKManagerAdapter.initState = kAdScopeMediationAdapterInitSDKStateLoad;
    [ADJgSDK setLogLevel:ADJgKitLogLevelDebug];
    [ADJgSDK initWithAppId:appId completionBlock:^(NSError * _Nonnull error) {
        if (error) {
            if (AMPSADJGSDKManagerAdapter.initState != kAdScopeMediationAdapterInitSDKStateSuccess) {
                AMPSADJGSDKManagerAdapter.initState = kAdScopeMediationAdapterInitSDKStateFail;
            }
            adapterResult(NO);
        } else {
            AMPSADJGSDKManagerAdapter.initState = kAdScopeMediationAdapterInitSDKStateSuccess;
            adapterResult(YES);
        }
    }];
}

+ (void)setPersonalizedRecommendState:(BOOL)state {
    [ADJgSDK setEnablePersonalAd:state];
}

+ (NSString *)sdkVersion {
    return [ADJgSDK getSDKVersion];
}

+ (nonnull NSString *)adapterVersion {
    return @"适配器版本";
}

@end
